﻿<%@page import="com.railway.msg.model.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
	<head>
		<title>未读用户列表</title>		
	    <%@ include file="/commons/listcssjs.jsp" %>	   
		<script type="text/javascript">   
	            $(document).ready(function() { 	            
	              if($.browser.msie) {				   
                  }else{
                 //火狐浏览器会存在页面不刷新的问题,因此再查一次,这种处理比较恶心,但是见效比较快
	                $.get("${ctx}/msg/MsgRecive/listAjaxUnreadUsers.do", {	            
                        Action:"get",msgId:queryForm.msgId.value}, function (data, textStatus){		
                        data = eval('('+data+')');
				        $('#userDataGrid').datagrid("loadData",data);  				              
				});		
				}
							
	        }); 
	        </script>
	</head>
	<body>
		<div style="width: 1000px; padding: 0px;">
			<form id="queryForm" name="queryForm"
				action="${ctx}/msg/MsgRecive/listAjaxUnreadUsers.do" method="post"
				style="display:inline;">
				<input type="hidden" id="pageNumber" name="pageNumber" value="1" />
				<input type="hidden" id="pageSize" name="pageSize" value="10" />
				<input type="hidden" id="msgId" name="msgId" value="<%=request.getParameter("msgId") %>" />
				<div class="queryPanel">

				</div>
				<br></br>
				<div>
					<table id="userDataGrid"></table>
					
				</div>
			</form>
		</div>
		
					

   <div id="basedialog"></div>
	</body>
	<script type="text/javascript">
/**用于回调*/
	 function v_deleteItems(result){
			if (result){
				var rows = $('#userDataGrid').datagrid('getSelections');
				var ids = [];
				if(rows!=null&&rows.length>0){
					$.each(rows,function(i,n){ids.push(n.id)
					});
					$.post( "${ctx}/msg/MsgRecive/delete.do", {"items":ids.join(',')}, 
							function(data){
								$.messager.alert('提示','删除成功','info');
								$('#queryForm').submit();
							}
					);
				}else{
			
					$.messager.alert("提示","请选择后进行删除操作！");
				}
			}
		}
		var option = {
				title:'未读用户列表',
				iconCls:'icon-save',
				width:300,
				height:500,
				nowrap: false,
				striped: true,
				collapsible:true,
				url: "${ctx}/msg/MsgRecive/listAjaxUnreadUsers.do?msgId="+queryForm.msgId.value,                                                       
				remoteSort: false,
				idField:'id'																				,
				columns:[[
				{field:'recivor',title:'<%=MsgRecive.ALIAS_RECIVOR%>',width:120,sortable:true}
				,{field:'status',title:'<%=MsgRecive.ALIAS_STATUS%>',width:120,sortable:true}	
		
				]],
				pagination:true,
				rownumbers:true,
				toolbar:[],
				onLoadSuccess: function(){
	            	function bindRowsEvent(){
		                var panel = $('#userDataGrid').datagrid('getPanel');
		                var rows = panel.find('tr[datagrid-row-index]');
		                rows.unbind('click').bind('click',function(e){
		                    return false;
		                });
		                rows.find('div.datagrid-cell-check input[type=checkbox]').unbind().bind('click', function(e){
		                    var index = $(this).parent().parent().parent().attr('datagrid-row-index');
		                    if ($(this).attr('checked')){
		                        $('#userDataGrid').datagrid('selectRow', index);
		                    } else {
		                        $('#userDataGrid').datagrid('unselectRow', index);
		                    }
		                    e.stopPropagation();
		                });
		            }
		            setTimeout(function(){
		                bindRowsEvent();
		            }, 10);    
	    		}
			}


		//重要$(document).ready(handler)
		$(function(){
			//设置form为ajax提交		
			$('#queryForm').form({
				success:function(data){
				data = eval('('+data+')');
				$('#userDataGrid').datagrid("loadData",data);
				}
			});
			//设置datagrid		
			$('#userDataGrid').datagrid(option);
			//设置底部的上一页和下一页
			var p = $('#userDataGrid').datagrid('getPager');
			if (p){
				$(p).pagination({
					onBeforeRefresh:function(){
					//	alert('before refresh');
					}
				});
				$(p).pagination({
					onSelectPage:function(pageNumber,pageSize){
						$("input[name='pageNumber']").val(pageNumber);
						$("input[name='pageSize']").val(pageSize);
						$('#queryForm').submit();
					}
				});
			}}
		); //end $(document).ready(handler)
		//以下这些方法放在这几是为了提供编写javascript参考用，可根据实际情况删除
		function resize(){
			$('#userDataGrid').datagrid('resize', {
				width:1100,
				height:400
			});
		}
		function getSelected(){
			var selected = $('#userDataGrid').datagrid('getSelected');
			if (selected){
				alert(selected.id);
			}
		}
		function getSelections(){
			var ids = [];
			var rows = $('#userDataGrid').datagrid('getSelections');
			for(var i=0;i<rows.length;i++){
				ids.push(rows[i].id);
			}
			alert(ids.join(':'));
		}
		function clearSelections(){
			$('#userDataGrid').datagrid('clearSelections');
		}
		function selectRow(){
			$('#userDataGrid').datagrid('selectRow',1); //行号从0开始
		}
		function selectRecord(){
			$('#userDataGrid').datagrid('selectRecord','1'); //'1'是id值
		}
		function unselectRow(){
			$('#userDataGrid').datagrid('unselectRow',1);//行号从0开始
		}
	</script>
</html>